<?php
/**
 * User: Beyond_dream
 * Date: 2016/9/12 19:34
 * 获取牌局播放的详细数据
 * request: GetRoundDetail
 */
class GetRoundDetail extends RegisterBase
{
    public function logic()
    {
        if (!isset($this->params['paiZuID']) || !isset($this->params['index'])) {
            $this->returnError('exception_input');
        }

        $key = 'PJL:' . $this->params['paiZuID'] . $this->params['index'];
        $paijuRedis = $this->redis('paiju_log');

        if ( ! $paijuRedis->exists($key)) {
            $this->returnError('no_paiju_id');
        }

        $data = [];
        $detail = $paijuRedis->hget($key, 'detail');
        $detail = json_decode($detail, JSON_UNESCAPED_UNICODE);

        if (isset($detail['orders'])) {
            $data['detail'] = $detail['orders'];
        }

        if (empty($data['detail'])) {
            $this->returnError('no_paiju_detail');
        }

        $this->returnData('suc_action', $data);
    }

}